package com.ruoyi.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/hotel/log")
public class LogController extends BaseController {

    @Autowired
    LogService logService;

    @GetMapping("/getRoomStatusLog")
    public TableDataInfo getRoomStatusLog(@RequestParam Map map) {
        // 本地的酒店ID
        startPage();
        List<String> logTypeList = StringUtils.getListStringByMap(map, "logType");
        List<String> dateRangeList = StringUtils.getListStringByMap(map, "dateRange");
        map.put("logTypeList",logTypeList);
        if(dateRangeList.size() > 0){
            map.put("startTime",dateRangeList.get(0));
            map.put("endTime",dateRangeList.get(1));
        }
        List<Map> houseLog = logService.getHouseLog(map);
        return getDataTable(houseLog);
    }
}
